package A14;

import java.util.Date;
import java.util.List;

public class Order {
    // 订单状态枚举（内部枚举，与Order强关联）
    public enum OrderStatus {
        CREATE, PAID, SHIPPING, DELIVERED, CANCEL
    }

    private Date createDate; // 创建日期
    private OrderStatus status; // 订单状态
    private List<OrderDetail> orderDetails; // 组合：1~*个订单详情
    private Payment payment; // 关联：1种支付方式

    public Order(Date createDate, OrderStatus status) {
        this.createDate = createDate;
        this.status = status;
    }

    // 添加订单详情
    public void addOrderDetail(OrderDetail orderDetail) {
        if (orderDetails == null) {
            throw new IllegalStateException("请先初始化orderDetails集合！");
        }
        orderDetails.add(orderDetail);
    }

    // 设置支付方式
    public void setPayment(Payment payment) {
        this.payment = payment;
    }

    // getter/setter
    public Date getCreateDate() {
        return createDate;
    }

    public OrderStatus getStatus() {
        return status;
    }

    public void setStatus(OrderStatus status) {
        this.status = status;
    }

    public List<OrderDetail> getOrderDetails() {
        return orderDetails;
    }

    public void setOrderDetails(List<OrderDetail> orderDetails) {
        this.orderDetails = orderDetails;
    }

    public Payment getPayment() {
        return payment;
    }
}
